def check_config_compatibility(cfg_path, weights_path):
    """检查配置文件和权重文件的匹配性"""
    print("=== 配置文件检查 ===")
    print(f"配置文件路径: {cfg_path}")

    # 读取并显示配置文件内容
    with open(cfg_path, 'r', encoding='utf-8') as f:
        config_content = f.read()
        print("配置文件内容:")
        print(config_content)

    print("\n=== 权重文件检查 ===")
    print(f"权重文件路径: {weights_path}")

    # 检查权重文件信息
    weights = torch.load(weights_path, map_location='cpu')
    print(f"权重文件类型: {type(weights)}")

    if isinstance(weights, dict):
        print("权重文件键:")
        for key in weights.keys():
            print(f"  - {key}")

        # 如果是包含 'model' 键的字典
        if 'model' in weights:
            model_weights = weights['model']
            print(f"模型权重键数量: {len(model_weights)}")
            # 检查是否有 pos_embed
            if 'base.pos_embed' in model_weights:
                pos_embed_shape = model_weights['base.pos_embed'].shape
                print(f"pos_embed 形状: {pos_embed_shape}")

    return config_content, weights


# 在 main 函数开头调用
def main(args):
    # 检查匹配性
    config_content, weights = check_config_compatibility(args.config_file, args.reid_weights)

